﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;

namespace AjaxDemo.Controllers
{
    public class ProductController : Controller
    {
        EShopV10 db = new EShopV10();
        
        public ActionResult LoadForm()
        {
            int rowCount = db.Products.Count();
            ViewBag.PageCount = Math.Ceiling(1.0 * rowCount / 6);
            return View();
        }

        public ActionResult LoadMore(int PageNo)
        {
            var model = db.Products.ToList()
                .Skip(PageNo * 6).Take(6);
            Thread.Sleep(5000);
            return PartialView(model);
        }

        //--PHÂN TRANG--//

        public ActionResult PaginateForm()
        {
            int rowCount = db.Products.Count();
            ViewBag.PageCount = Math.Ceiling(1.0 * rowCount / 6);
            return View();
        }

        public ActionResult LoadPage(int PageNo)
        {
            var model = db.Products.ToList()
                .Skip(PageNo * 6).Take(6);
            return PartialView(model);
        }
	}
}